//
//  ZHMacro.h
//  ToolsEnginer
//
//  Created by 正合适 on 2017/6/12.
//  Copyright © 2017年 正合适. All rights reserved.
//  宏定义

#ifndef ZHMacro_h
#define ZHMacro_h

#pragma mark - ---------- 颜色类 ----------
// 16进制颜色
#define k16RGBColor(rgbValue) \
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 \
green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 \
blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:1.0]

#define kRGBAColor_16(hexValue) [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16)) / 255.0 green:((float)((hexValue & 0xFF00) >> 8)) / 255.0 blue:((float)(hexValue & 0xFF)) / 255.0 alpha:1.0f
#define kRGBAColor(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:a]
#define kRGBColor(r,g,b)    kRGBAColor((r),(g),(b),1)
#define kWhiteColor         [UIColor whiteColor]
#define kBlackColor         [UIColor blackColor]
#define kGrayColor          [UIColor grayColor]
#define kRedColor           [UIColor redColor]
#define kGreenColor         [UIColor greenColor]
#define kBlueColor          [UIColor blueColor]
#define kCyanColor          [UIColor cyanColor]
#define kMagentaColor       [UIColor magentaColor]
#define kYellowColor        [UIColor yellowColor]
#define kClearColor         [UIColor clearColor]

#pragma mark - ---------- 尺寸类 ----------
#define kScreenWidth        [UIScreen mainScreen].bounds.size.width
#define kScreenHeight       [UIScreen mainScreen].bounds.size.height

#pragma mark - ---------- 字体类 ----------
#define kFont(a)            [UIFont systemFontOfSize:(a)]

#pragma mark - ---------- 图片类 ----------
#define kUIImage(imgStr)           [UIImage imageNamed:(imgStr)]

#pragma mark - ---------- 安全执行类 ----------
// 安全执行block
#define kSafeBlcok(A,...)   if(A){A(__VA_ARGS__);}
// weakSelf
#define kWeakSelf           __weak typeof(self) weakSelf = self
#define kWeakObject(object) __weak __typeof(object) weakObject = object;

#pragma mark - ---------- 系统信息类 ----------
// 系统版本
#define kIOSVersion [UIDevice currentDevice].systemVersion.floatValue

#pragma mark - ---------- 通知缓存类 ----------
// userdefaults存
#define kUserDefaultSetObjectForKey(__VALUE__,__KEY__) \
{\
[[NSUserDefaults standardUserDefaults] setObject:__VALUE__ forKey:__KEY__];\
[[NSUserDefaults standardUserDefaults] synchronize];\
}

// userdefaults取
#define kUserDefaultObjectForKey(__KEY__)  [[NSUserDefaults standardUserDefaults] objectForKey:__KEY__]

// userdefaults删
#define kUserDefaultRemoveObjectForKey(__KEY__) \
{\
[[NSUserDefaults standardUserDefaults] removeObjectForKey:__KEY__];\
[[NSUserDefaults standardUserDefaults] synchronize];\
}

// 发送通知
#define kPostNotificationWithName(notificationName) \
[kNotificationCenter postNotificationName:notificationName object:nil userInfo:nil]
// 发送通知并携带信息
#define kPostNotificationWithNameAndUserInfo(notificationName, userInfo) \
[kNotificationCenter postNotificationName:notificationName object:nil userInfo:userInfo]

#pragma mark - ---------- 判断类 ----------
// 验证字符串是否为空
#define kIsEmptyString(s) (s == nil || [s isKindOfClass:[NSNull class]] || ([s isKindOfClass:[NSString class]] && s.length == 0))

#pragma mark - ---------- 其他类 ----------
// appdelegate
#define kAppDelegate ((AppDelegate *)[[UIApplication  sharedApplication] delegate])

#endif /* ZHMacro_h */
